package com.isp.org.server.domain.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isp.org.api.dto.menu.SysMenu;
import com.isp.org.server.domain.entity.RoleMenuEntity;
import com.isp.org.server.domain.mapper.RoleMenuMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/3/12 17:36
 */
@Service
@RequiredArgsConstructor
public class RoleMenuService extends ServiceImpl<RoleMenuMapper, RoleMenuEntity> {

    private final RoleMenuMapper roleMenuMapper;

    public List<SysMenu> findMenusByRoleCodes(String app, Set<String> roleCodes, Integer type) {
        return roleMenuMapper.findMenusByRoleCodes(app, roleCodes, type);
    }

    public void deleteById(Long id) {
        super.removeById(id);
    }

    public List<SysMenu> findMenusByRoleIds(String app, Set<Long> roleIds, Integer type) {
        return roleMenuMapper.findMenusByRoleIds(app, roleIds, type);
    }

    public List<SysMenu> findAll(String app) {
        return roleMenuMapper.findAll(app);
    }

    public void delete(Long roleId, Long menuId) {
        roleMenuMapper.delete(roleId, menuId);
    }

    public void saveAll(List<RoleMenuEntity> roleMenu) {
        this.saveAll(roleMenu);
    }
}
